package io.youngledo.usb.exception;

/**
 * 存储连接异常
 */
public class StorageConnectionException extends UniversalStorageException {

    public StorageConnectionException(String message) {
        super(ErrorType.CONNECTION_FAILED, message);
    }

    public StorageConnectionException(String message, Throwable cause) {
        super(ErrorType.CONNECTION_FAILED, null, message, cause);
    }

    public static StorageConnectionException authenticationFailed(String message) {
        return new StorageConnectionException(message) {
            @Override
            public ErrorType getErrorType() {
                return ErrorType.AUTHENTICATION_FAILED;
            }
        };
    }

    public static StorageConnectionException networkError(String message, Throwable cause) {
        return new StorageConnectionException(message, cause) {
            @Override
            public ErrorType getErrorType() {
                return ErrorType.NETWORK_ERROR;
            }
        };
    }
}